home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 27.zip
/
BS1 part 27
/
PhonepakV2_d1.adf
/
rexx
/
Forwarding.ppak
< prev
next >
Wrap
Text File
|
1993-04-28
|
7KB
|
171 lines
/****************************************************************************/
/* PhonePak ARexx script for Message Forwarding */
/* */
/* LineMan is expecting a result string consisting of a number and a */
/* message. PhonePak's schedule listing can display a message up to 15 */
/* characters long. If the number is less than zero, the error is */
/* considered fatal and no further attempts will be made. Zero means */
/* success; the forwarding liability will be reset. Greater than zero */
/* represents the number of minutes to wait before trying again; this is */
/* therefore a retriable error. */
/****************************************************************************/
/***************/
/* Constants */
/***************/
interval = 10 /* Minutes before next attempt */
maxlines = 5 /* Maximum number of phone lines */
maxattempts = 15 /* Maximum number of retries */
/****************************************************************************/
options failat 101
options results
arg PhoneNumber /* Get args handed in by LineMan */
Mailbox = GetDirName(PRAGMA('d')) /* Get mailbox name (current dir) */
Upper Mailbox /* Make sure its upper case */
/***********************************/
/* Try to find an available line */
/***********************************/
x = 1
do forever
PortName = 'LINEMAN.' || x /* Assemble the port name */
if show('P', PortName) then do /* See if the port is present */
address value PortName /* Modify host address */
SETMAILBOX Mailbox /* Get mailbox info */
if rc = 0 then do
if word(result,3) = IN then
exit interval "'MB is marked IN'"
else
call Forward() /* Only returns if call should */
end /* be attempted on another line */
else if rc != 98 & rc != 99 then
exit "-1 'Script error'" /* Outer quotes get stripped */
end
if x = maxlines then
exit interval "'Line not avail'" /* Outer quotes get stripped */
else
x = x + 1 /* Increment line # and continue */
end
/*********************************/
/* SUBROUTINE */
/* Attempt to forward messages */
/*********************************/
Forward:
OpString = '<O><D>' PhoneNumber '<C><W15>'
OPERATOR OpString /* Dial the phone number */
DialResult = rc
if DialResult ~= 0 then /* Hang up on error */
Operator '<H>'
select
when DialResult = -3 then /* Make sure phone # is 'raw' */
exit "-1 'Procedure error'"
when DialResult = -2 then /* Probably a missing message */
exit "-1 'I/O error'"
when DialResult = -1 then
exit "-1 'Syntax error'"
when DialResult = 0 then
nop
when DialResult = 1 then
exit interval "'Resource error'"
when DialResult = 2 then
exit interval "'Local pickup'"
when DialResult = 4 then
return
when DialResult = 5 then
exit interval "'No dialtone'"
when DialResult = 6 then do
if TryAgain() = TRUE then /* Limit number of attempts */
exit interval "'No answer'"
else
exit "-1 'Hit retry limit'"
end
when DialResult = 8 then do
if TryAgain() = TRUE then /* Limit number of attempts */
exit interval "'Busy signal'"
else
exit "-1 'Hit retry limit'"
end
when DialResult = 98 | DialResult = 99 then
return
otherwise
exit "-1 'Fatal error'"
end
setclip(Mailbox || ATTEMPTS, 0) /* Reset busy attempts */
/****************************************************************************/
/* The called party will hear "x new messages. Please enter your password */
/* now" upon answering the phone. If you would like to make this script */
/* a little more sophisticated, you could insert a PLAYBACK command here */
/* to play a message that says something like "This is an automated call */
/* for John; please call him to the phone." If you put the message in */
/* in John's mailbox, the filename in the PLAYBACK command will not require */
/* a path specification, since the current directory is already set to */
/* John's mailbox. You might play the message three times or so, while you */
/* wait for John to press 1 or some other DTMF code to indicate that the */
/* script should proceed. You could even play a message that tells the */
/* called party what to do if John is not available (e.g., call back in */
/* thirty minutes, sixty minutes, or not at all), modifying the script's */
/* exit code according to the called party's response. */
/****************************************************************************/
REMOTEACCESS Mailbox /* Initiate remote access */
RAResult = rc /* Stash result */
Operator '<H>' /* Hang up when finished */
select
when RAResult = -3 then
exit "-1 'Bad Password'"
when RAResult = -2 then
exit "-1 'I/O error'"
when RAResult = -1 then
exit "-1 'Syntax error'"
when RAResult = 1 then
exit interval "'Resource error'"
otherwise
exit /* Success! */
end
/***********************************/
/* SUBROUTINE */
/* Get name of current directory */
/***********************************/
GetDirName:
path = arg(1)
n = lastpos("/",path)
if n=0 then
n = lastpos(":",path)
return substr(path, n+1)
/***********************************/
/* SUBROUTINE */
/* Determine if retries remain */
/***********************************/
TryAgain:
x = getclip(Mailbox || ATTEMPTS)
if x = '' then x = 0
x = x + 1
if x = maxattempts then do
x = 0
setclip(Mailbox || ATTEMPTS, x)
return FALSE
end
setclip(Mailbox || ATTEMPTS, x)
return TRUE